using System;
using System.Collections.Generic;
using SciptableObject;
using UnityEngine;
using SoundName=Utilities.SoundName;

namespace Utilities
{
    public static class EventHandler
    {
        public static String log = "kais";
        public static event Action<MiniPeopleEventType> OnWeatherActivate; //天气事件通知

        public static void CallOnWeatherActivate(MiniPeopleEventType weatherType)
        {
            OnWeatherActivate?.Invoke(weatherType);
        }


        public static event Action<int> WeatherTimerTimeOut; //时钟TimeOut广播，type为类型，id为类型下的id
        public static event Action<int> MiniPeopleTimerTimeOut; 
        public static void CallTimerTimeOut(int type, int id)
        {
            switch (type) //遍历type所指类型
            {
                case 0:WeatherTimerTimeOut?.Invoke(id); //天气时钟TimeOut广播
                    break;
                case 1:MiniPeopleTimerTimeOut?.Invoke(id); //小人物时钟TimeOut广播
                    break;
                default:
                    break;
            }
        }

        #region 开启事件小人说话
        public static event Action<MiniPeopleRequestEvent> MiniPeopleSpeek;

        public static void CallMiniPeopleSpeek(MiniPeopleRequestEvent eventItem)
        {
            MiniPeopleSpeek?.Invoke(eventItem);
        }
        #endregion
        #region 数据中心控制器

            #region 收取数据
            public static event Action<List<EventRewordData>,bool> GameDataValueSend;
        
            public static void CallGameDataValueSend(List<EventRewordData> data,bool falg)
            {
                GameDataValueSend?.Invoke(data,falg);
            }

            #endregion

            #region 传递数据
            
            public static event Action<GameValues> ValueToUI;

            public static void CallValueToUI(GameValues data)
            {
                ValueToUI?.Invoke(data);
            }
            
            public static event Action<float> FaithValueToUI;
            
            public static void CallFaithValueToUI(float data)
            {
                FaithValueToUI?.Invoke(data);
            }
            
            #endregion
        
        #endregion
        
        public static event Action<SoundName> PlaySoundEvent; //通知AudioManager初始化音效
        public static void CallPlaySoundEvent(SoundName soundName)
        {
            PlaySoundEvent?.Invoke(soundName);
        }
        public static event Action<SoundDetails> InitSoundEffect; //通知SoundPool载入音效
        public static void CallInitSoundEffect(SoundDetails soundDetails)
        {
            InitSoundEffect?.Invoke(soundDetails);
        }
        

        #region 检测器广播

        public static event Action EnterTriggerColl;

        public static void CallEnterTrigger() => EnterTriggerColl?.Invoke();

        #endregion

        #region 广播卡槽占用信息

        public static event Action<int> ClearingCardsSlot; //卡槽占用信息广播

        public static void CallClearingCardsSlot(int index)
        {
            ClearingCardsSlot?.Invoke(index);
        }

        #endregion

        #region 游戏失败后的GameValue广播

        public static event Action<GameValues> GameOverValue;

        public static void CallGameOverValue(GameValues value)
        {
            GameOverValue?.Invoke(value);
        }

        #endregion
    }
}
